Sharp Stuff
Switchblades Icepicks and german knives
PHP Gallery
PHP Gallery is a free php image script.
Viking gear
Gear Gifts and Apparel
Sell your soul
Believeth in me an hath everlasting life

here are some of the best and useful php scripts and snippets to help in your projects. Php displayed below. Use the search for specific script lookups. Click the category links to view scripts in Javascript and cgi. To add your own script click the link and add your useful script example.

csv class parse a csv type delimited file into an associative indexed by the first row values
file dat array csv delimiter file

<?php

    
class CSVData{
    public 
$file;
    public 
$data;
    public 
$fp;
    public 
$caption=true;
    public function 
CSVData($file=''){
        if (
$file!=''getData($file);
    }
    function 
getData($file){
        if (
strpos($file'tp://')!==false){
            
copy ($file'csvdata.txt');
            if (
$this->fp=fopen('csvdata.txt''r')!==FALSE){
                
$this->readCSV();
                
unlink('csvdata.txt');
            }
        } else {
            
$this->fp=fopen($file'r');
            
$this->readCSV();
        }
        
fclose($this->fp);
    }
    private function 
readCSV(){
        if (
$this->caption==true){
            if ((
$captions=fgetcsv($this->fp1000";"))==false) return false;
        }
        
$row=0;
        while ((
$data fgetcsv($this->fp1000";")) !== FALSE) {
            for (
$c=0$c count($data); $c++) {
                
$this->data[$row][$c]=$data[$c];
                if (
$this->caption==true){
                    
$this->data[$row][$captions[$c]]=$data[$c];
                }
            }
            
$row++;
        }
    }
}


    
$o=new CSVData();
$o->getData('cart-data2.txt');
$data=$o->data;
 foreach (
$data as $key=>$val)
{
  echo 
"<b>$key:</b> $val[$key]<br/>";
 
//   echo "$val[$key]<br/>";
//echo "$key[2]<br/>";
 
}
 
?>


Add your comment.













No comments yet

Search ScriptsnTips


Php JavaScripts CGI/Perl